const baseKey = "slow-"

// 缓存token
export const setToken = (token: string) => {
    localStorage.setItem(baseKey + "token", token)
}

// 获取token
export const getToken = () => {
    return localStorage.getItem(baseKey + "token")
}

// 缓存用户信息
export const setUserInfo = (userInfo: any) => {
    localStorage.setItem(baseKey + "userInfo", JSON.stringify(userInfo))
}

// 获取用户信息
export const getUserInfo = () => {
    return JSON.parse(<string>localStorage.getItem(baseKey + "userInfo"))
}

// 清除登录信息
export const clearLoginInfo = () => {
    localStorage.removeItem(baseKey + "token")
    localStorage.removeItem(baseKey + "userInfo")
    localStorage.removeItem(baseKey + "menuInfo")
}

// 缓存菜单信息
export const setMenuInfo = (menuInfo: any) => {
    localStorage.setItem(baseKey + "menuInfo", JSON.stringify(menuInfo))
}

// 获取菜单信息
export const getMenuInfo = () => {
    return JSON.parse(<string>localStorage.getItem(baseKey + "menuInfo"))
}
